<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script>
  // 注意对象里面的函数叫方法
  {
    let obj = {
      name: "cz",
      show() { //对象里面的方法，this是指向对象的本身
        console.log(this.name);
        let da = function () {
          console.log(this);
        };

        da(); //此时da函数里面的this，指向了window了
      }
    };

    obj.show();
  };

  {
    // 构造函数
    let user = function (name) {
      this.name = name;
      this.show = () => {
        console.log(this); //此时的this仍然指向window
      };
    };
  }
</script>

</html>